<?php

if(isset($_POST['filIdEdit']) && isset($_POST['filNameEdit']) && isset($_POST['filLinkEdit']) && isset($UID)){
#if it is a dirAdd request

  $filIdEdit   = $_POST['filIdEdit'];
  $filNameEdit = $_POST['filNameEdit'];
  $filLinkEdit = $_POST['filLinkEdit'];

  require_once $BASE_PATH . 'm/fil.php';

  $filcn = new FIL(DBHOST, DBUSER, DBPASS, DBNAME);

  $filEdit = $filcn->getById($filIdEdit);

  if($filEdit !== false){

    if($filcn->alt($filEdit['id'], $filEdit['parent'], $filNameEdit, $filLinkEdit, $filEdit['uid'])){

      require_once $BASE_PATH . 'm/bookmark.php';
      $bmcn = new Bookmark(DBHOST, DBUSER, DBPASS, DBNAME);
      $bookmark = $bmcn->get($UID);

      echo '{"code": 0, "data":' . json_encode($bookmark) . '}';

    }else{

      echo '{"code": 1, "message": "fail to change fil"}';

    }

  }else{

    echo '{"code": 2, "message": "fail to get fil"}';

  }

}
